home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.6 KB | 279 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMnuBar.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMNUBAR_H
- #define FWMNUBAR_H
-
- #ifndef FWPULLDM_H
- #include "FWPullDM.h"
- #endif
-
- #ifndef FWCOMMON_H
- #include "FWCommon.h"
- #endif
-
- #ifndef FWDEBUG_H
- #include "FWDebug.h"
- #endif
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- // ----- Platform Includes -----
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <windows.h>
- #endif
-
- //========================================================================================
- // Forward class definitions
- //========================================================================================
-
- class ODPart;
- class FW_CString;
- class FW_CMenuItem;
-
- //========================================================================================
- // class FW_CMenuBar
- //========================================================================================
-
- class FW_CMenuBar
- {
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_DECLARE_AUTO(FW_CMenuBar)
-
- FW_CMenuBar(Environment* ev, ODPart* thePart, FW_Instance partInstance);
- virtual ~FW_CMenuBar();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- // ----- Adding -----
- void InitializeFromResource(Environment* ev, FW_ResourceID menuBarResourceID);
- void InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
-
- void AdoptMenuFirst(Environment* ev,
- FW_CPullDownMenu* menu);
- void AdoptMenuLast(Environment* ev,
- FW_CPullDownMenu* menu);
-
- void AdoptMenuBefore(Environment* ev,
- FW_CPullDownMenu* menu,
- FW_CPullDownMenu* beforeMenu); // if beforeMenu == NULL -> AdoptMenuFirst
- void AdoptMenuAfter(Environment* ev,
- FW_CPullDownMenu* menu,
- FW_CPullDownMenu* afterMenu); // if afterMenu == NULL -> AdoptMenuLast
-
- // ----- Removing/Detaching -----
- void DetachMenu(Environment* ev,
- FW_CPullDownMenu* menuToDetach);
- void DeleteMenu(Environment* ev,
- FW_CPullDownMenu* menuToDelete); // DetachMenu + delete of the menu
- void DeleteAll(Environment* ev);
-
- void RemoveItem(Environment* ev, ODCommandID commandID);
-
- // ----- Item access -----
- void SetItemString(Environment* ev,
- ODCommandID commandID,
- const FW_CString& itemString);
- void GetItemString(Environment* ev,
- ODCommandID commandID,
- FW_CString& itemString) const;
-
- FW_CString GetAboutString(Environment* ev) const;
-
- void EnableCommand(Environment* ev,
- ODCommandID cmdNumber,
- FW_Boolean enable);
- void CheckCommand(Environment* ev,
- ODCommandID cmdNumber,
- FW_Boolean check);
- void ToggleItem(Environment* ev,
- ODCommandID cmdNumber,
- FW_Boolean toggleState);
-
- void EnableAndCheckCommand(Environment* ev,
- ODCommandID cmdNumber,
- FW_Boolean enable,
- FW_Boolean check);
- void EnableAndToggleCommand(Environment* ev,
- ODCommandID cmdNumber,
- FW_Boolean enable,
- FW_Boolean toggleState);
-
- FW_MenuKey GetMenuKey(Environment* ev, ODCommandID cmdNumber) const;
- void SetMenuKey(Environment* ev, ODCommandID cmdNumber, FW_MenuKey menuKey);
-
- void DisableAll(Environment* ev);
- void EnableAll(Environment* ev);
-
- // ----- Getters/Setters -----
- FW_CMenuItem* GetMenuItemFromCommand(Environment* ev,
- ODCommandID cmdNumber) const;
-
- ODMenuBar* AcquireODMenuBar(Environment* ev) const;
- ODPart* GetODPart(Environment* ev) const;
-
- FW_CPullDownMenu* FindMenuWithID(Environment* ev, ODMenuID menu) const;
-
- //----------------------------------------------------------------------------------------
- // Internal API
- //
- public:
- void PrivDisplay(Environment* ev);
-
- ODMenuID PrivGetNewMenuID(Environment* ev);
-
- #ifdef FW_BUILD_MAC
- void PrivMacEnableParentItem(Environment* ev,
- ODCommandID cmdNumber);
-
- void PrivMacRegisterCommand(Environment* ev,
- ODCommandID commandID,
- ODMenuID menuID,
- short itemID);
- void PrivMacUnregisterCommand(Environment* ev,
- ODCommandID commandID);
- ODCommandID PrivMacGetCommand(Environment* ev,
- ODMenuID menuID,
- short itemID);
-
- #endif
-
- void PrivAddSubMenu(Environment* ev,
- ODMenuID subMenuID,
- ODPlatformMenu platformMenu);
- void PrivRemoveMenu(Environment* ev,
- ODMenuID menuID);
-
- //----------------------------------------------------------------------------------------
- // Platform specific API
- //
- #ifdef FW_BUILD_MAC
- public:
- // ----- Enable/Disable of the whole menuBar -----
- void MacEnableMenuBar(Environment* ev,
- FW_Boolean enable);
- #endif
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- ODMenuBar* fODMenuBar;
- ODPart* fODPart;
- FW_TOrderedCollection<FW_CPullDownMenu>* fPullDownMenuList;
- ODMenuID fNextMenuID;
- FW_Instance fPartInstance;
- FW_CString fAboutString;
- };
-
- //========================================================================================
- // FW_CMenuBar inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivDisplay
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuBar::PrivDisplay(Environment* ev)
- {
- fODMenuBar->Display(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::GetODPart
- //----------------------------------------------------------------------------------------
- inline ODPart* FW_CMenuBar::GetODPart(Environment*) const
- {
- return fODPart;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivGetNewMenuID
- //----------------------------------------------------------------------------------------
- inline ODMenuID FW_CMenuBar::PrivGetNewMenuID(Environment*)
- {
- FW_ASSERT(fNextMenuID < 254); // was 255; now 255 is used for unattached menu ID
- return fNextMenuID++;
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivMacRegisterCommand
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuBar::PrivMacRegisterCommand(Environment* ev,
- ODCommandID commandID,
- ODMenuID menuID,
- short itemID)
- {
- fODMenuBar->RegisterCommand(ev, commandID, menuID, itemID);
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivMacUnregisterCommand
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuBar::PrivMacUnregisterCommand(Environment* ev,
- ODCommandID commandID)
- {
- fODMenuBar->UnregisterCommand(ev, commandID);
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivMacGetCommand
- //----------------------------------------------------------------------------------------
- inline ODCommandID FW_CMenuBar::PrivMacGetCommand(Environment* ev,
- ODMenuID menuID,
- short itemID)
- {
- return fODMenuBar->GetCommand(ev, menuID, itemID);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivAddSubMenu
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuBar::PrivAddSubMenu(Environment* ev,
- ODMenuID subMenuID,
- ODPlatformMenu platformMenu)
- {
- #ifdef FW_BUILD_MAC
- fODMenuBar->AddSubMenu(ev, subMenuID, platformMenu, fODPart);
- #endif
- #ifdef FW_BUILD_WIN
- // [WIN_PORT] AddSubMenu is missing in OpenDoc/Win!
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuBar::PrivRemoveMenu
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuBar::PrivRemoveMenu(Environment* ev,
- ODMenuID menuID)
- {
- fODMenuBar->RemoveMenu(ev, menuID);
- }
-
- #endif
-